def use_while1():
    i = 1
    while i <= 5:
        print(i)
        i += 1
    print('循环结束i的值为%d' % i)
    print(f'循环结束i的值为{i}')


def use_continue_break():
    sum = 0
    i = 1
    while True:
        if i > 100:
            break
        if i % 2 == 0:
            sum += i
        elif i % 2 == 1:
            i = i + 1
            continue
        i = i + 1

    print(f'100以内偶数求和为{sum},i的值为{i}')


def use_for1():
    my_list = ['a', 'b', 'c']
    print(my_list)
    # in后面必须是可迭代对象
    for i in my_list:
        print(i)
    print('-' * 50)
    # i在函数外也可使用
    print(i)


def use_for2():
    '''
    if-else句式
    :return:
    '''
    # range左闭右开，默认0开始
    for i in range(10):
        if i == 8:
            print(f'找到了{i}')
            break
    else:
        print('整体都没找到')
    print(i)


# use_while1()
# use_continue_break()
use_for1()
#use_for2()
